FROM php:8.2.17-zts-alpine3.19

LABEL image.authors="zhaoxiang"

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories \
    && apk add --no-cache tzdata \
    && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
    && echo "Asia/Shanghai" > /etc/timezone \
    && apk del tzdata \
    && apk add --no-cache \
            rabbitmq-c \
            rabbitmq-c-dev \
            openssh \
            zip \
            g++ \
            gcc \
            libc-dev \
            make \
            pcre-dev \
            zlib-dev \
            icu-dev \
            linux-headers \
            curl \
            gnupg \
            libxslt-dev \
            gd-dev \
            gd \
            geoip-dev \
            libstdc++ \
            wget \
            libjpeg \
            libpng \
            libpng-dev \
            freetype \
            freetype-dev \
            libxml2 \
            libxml2-dev \
            curl-dev \
            libmcrypt \
            libmcrypt-dev \
            autoconf \
            libjpeg-turbo-dev \
            libmemcached \
            libmemcached-dev \
            gettext \
            gettext-dev \
            libzip \
            git \
            libzip-dev \
    && pecl install -D 'enable-sockets="no" enable-openssl="yes" enable-http2="yes" enable-mysqlnd="no" enable-swoole-json="yes" enable-swoole-curl="yes" enable-cares="no"' swoole \
    && docker-php-ext-configure gd --with-freetype --with-jpeg \
    && docker-php-ext-install \
            bcmath \
            mysqli \
            pdo_mysql \
            pcntl \
            gd \
            gettext \
            bz2 \
            calendar \
            intl \
            shmop \
            sysvsem \
            xsl \
            zip \
            soap \
            sockets \
            zip \
            xsl \
    && pecl install -D 'enable-redis-igbinary="no" enable-redis-lzf="no" enable-redis-zstd="no"' redis \
    && pecl install -D 'enable-reader="yes"' xlswriter \
    && docker-php-ext-enable redis.so \
    && docker-php-ext-enable swoole.so \
    && echo "swoole.use_shortname='Off'" >> /usr/local/etc/php/conf.d/docker-php-ext-swoole.ini \
    && docker-php-ext-enable xlswriter.so \
    && mkdir /data/ && mkdir /data/share && mkdir /data/log \
    && cp /usr/local/etc/php/php.ini-development /usr/local/etc/php/php.ini \
    && sed -i 's/\;date.timezone\ =/date.timezone=PRC/g' /usr/local/etc/php/php.ini \
    && sed -i 's/\upload_max_filesize\ =\ 2M/upload_max_filesize\ =\ 128M/g' /usr/local/etc/php/php.ini \
    && sed -i 's/\post_max_size\ =\ 8M/post_max_size\ =\ 128M/g' /usr/local/etc/php/php.ini \
    && sed -i 's/\memory_limit\ =\ 128M/memory_limit\ =\ 1G/g' /usr/local/etc/php/php.ini

VOLUME /data

# RUN pecl install amqp

EXPOSE 8006
EXPOSE 9502
ENTRYPOINT ["/data/share/job/init_docker.sh"]
